{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "0",
   "metadata": {},
   "source": [
    "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/gee-community/geemap/blob/master/docs/workshops/Crop_Mapping_2022.ipynb)\n",
    "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/gee-community/geemap/master?urlpath=lab%2Ftree%2Fexamples%2Fworkshops)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1",
   "metadata": {},
   "source": [
    "**Cropland mapping with Google Earth Engine and geemap**\n",
    "\n",
    "Useful links\n",
    "\n",
    "- [Google Earth Engine](https://earthengine.google.com/)\n",
    "- [Sign up for an Earth Engine account](https://earthengine.google.com/signup/)\n",
    "- [Awesome GEE Community Datasets](https://samapriya.github.io/awesome-gee-community-datasets)\n",
    "- [Geemap website](https://geemap.org/)\n",
    "- [Geemap book](https://book.geemap.org/)\n",
    "- [Geemap YouTube videos](https://youtube.com/@giswqs)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2",
   "metadata": {},
   "outputs": [],
   "source": [
    "# !pip install geemap"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3",
   "metadata": {},
   "source": [
    "## Import libraries"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "4",
   "metadata": {},
   "outputs": [],
   "source": [
    "import ee\n",
    "import geemap"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5",
   "metadata": {},
   "source": [
    "## ESA WordCover\n",
    "\n",
    "The European Space Agency (ESA) WorldCover 10 m 2020 product provides a global land cover map for 2020 at 10 m resolution based on Sentinel-1 and Sentinel-2 data. The WorldCover product comes with 11 land cover classes and has been generated in the framework of the ESA WorldCover project, part of the 5th Earth Observation Envelope Programme (EOEP-5) of the European Space Agency.\n",
    "\n",
    "- [ESA WorldCover website](https://esa-worldcover.org/)\n",
    "- [EAS WroldCover in the Earth Engine Data Catalog](https://developers.google.com/earth-engine/datasets/catalog/ESA_WorldCover_v100)\n",
    "- [User Manual and Validation Report](https://esa-worldcover.org/en/data-access)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6",
   "metadata": {},
   "source": [
    "### Using Web Map Services\n",
    "\n",
    "The ESA WorldCover product can also be used within other websites or GIS clients by 'Web Map Services'. These services provide a direct link to the cached images and are the best option if you simply want to map the data and produce cartographic products. They are not suitable for analysis as the data are represented only as RGB images. \n",
    "\n",
    "- WMTS: https://services.terrascope.be/wmts/v2\n",
    "- WMS: https://services.terrascope.be/wms/v2\n",
    "- Layers: WORLDCOVER_2020_MAP, WORLDCOVER_2020_S2_FCC, WORLDCOVER_2020_S2_TCC"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "7",
   "metadata": {},
   "outputs": [],
   "source": [
    "Map = geemap.Map()\n",
    "\n",
    "esa_wms = \"https://services.terrascope.be/wms/v2\"  # The WMS URL\n",
    "tcc_layer = \"WORLDCOVER_2020_S2_TCC\"  # The true color composite imagery\n",
    "fcc_layer = \"WORLDCOVER_2020_S2_FCC\"  # The false color composite imagery\n",
    "map_layer = \"WORLDCOVER_2020_MAP\"  # The land cover classification map\n",
    "\n",
    "Map.add_wms_layer(esa_wms, layers=tcc_layer, name=\"True Color\", attribution=\"ESA\")\n",
    "Map.add_wms_layer(esa_wms, layers=fcc_layer, name=\"False Color\", attribution=\"ESA\")\n",
    "Map.add_wms_layer(esa_wms, layers=map_layer, name=\"Classification\", attribution=\"ESA\")\n",
    "\n",
    "Map.add_legend(title=\"ESA Land Cover\", builtin_legend=\"ESA_WorldCover\")\n",
    "Map"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8",
   "metadata": {},
   "source": [
    "### Using Earth Engine\n",
    "\n",
    "- [EAS WroldCover in the Earth Engine Data Catalog](https://developers.google.com/earth-engine/datasets/catalog/ESA_WorldCover_v100)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "9",
   "metadata": {},
   "outputs": [],
   "source": [
    "Map = geemap.Map()\n",
    "Map.add_basemap(\"HYBRID\")\n",
    "\n",
    "esa = ee.ImageCollection(\"ESA/WorldCover/v100\").first()\n",
    "esa_vis = {\"bands\": [\"Map\"]}\n",
    "\n",
    "Map.addLayer(esa, esa_vis, \"ESA Land Cover\")\n",
    "Map.add_legend(title=\"ESA Land Cover\", builtin_legend=\"ESA_WorldCover\")\n",
    "\n",
    "Map"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "10",
   "metadata": {},
   "source": [
    "### Creating charts"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "11",
   "metadata": {},
   "outputs": [],
   "source": [
    "histogram = geemap.image_histogram(\n",
    "    esa, scale=1000, x_label=\"Land Cover Type\", y_label=\"Area (km2)\"\n",
    ")\n",
    "histogram"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "12",
   "metadata": {},
   "outputs": [],
   "source": [
    "df = geemap.image_histogram(esa, scale=1000, return_df=True)\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "13",
   "metadata": {},
   "outputs": [],
   "source": [
    "esa_labels = list(geemap.builtin_legends[\"ESA_WorldCover\"].keys())\n",
    "esa_labels"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "14",
   "metadata": {},
   "outputs": [],
   "source": [
    "df[\"label\"] = esa_labels\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "15",
   "metadata": {},
   "outputs": [],
   "source": [
    "round(df[\"value\"].sum() / 1e6, 2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "16",
   "metadata": {},
   "outputs": [],
   "source": [
    "geemap.bar_chart(\n",
    "    df, x=\"label\", y=\"value\", x_label=\"Land Cover Type\", y_label=\"Area (km2)\"\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "17",
   "metadata": {},
   "outputs": [],
   "source": [
    "geemap.pie_chart(df, names=\"label\", values=\"value\", height=500)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "18",
   "metadata": {},
   "source": [
    "### Adding Administrative Boundaries"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "19",
   "metadata": {},
   "outputs": [],
   "source": [
    "countries = ee.FeatureCollection(geemap.examples.get_ee_path(\"countries\"))\n",
    "africa = countries.filter(ee.Filter.eq(\"CONTINENT\", \"Africa\"))\n",
    "style = {\"fillColor\": \"00000000\"}\n",
    "Map.addLayer(countries.style(**style), {}, \"Countries\", False)\n",
    "Map.addLayer(africa.style(**style), {}, \"Africa\")\n",
    "Map.centerObject(africa)\n",
    "Map"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "20",
   "metadata": {},
   "source": [
    "### Extracting Croplands"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "21",
   "metadata": {},
   "outputs": [],
   "source": [
    "cropland = esa.eq(40).clipToCollection(africa).selfMask()\n",
    "Map.addLayer(cropland, {\"palette\": [\"f096ff\"]}, \"Cropland\")\n",
    "Map.show_layer(name=\"ESA Land Cover\", show=False)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "22",
   "metadata": {},
   "source": [
    "### Zonal Statistics"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "23",
   "metadata": {},
   "outputs": [],
   "source": [
    "geemap.zonal_stats(cropland, africa, \"esa_cropland.csv\", stat_type=\"SUM\", scale=1000)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "24",
   "metadata": {},
   "outputs": [],
   "source": [
    "df = geemap.csv_to_df(\"esa_cropland.csv\")\n",
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "25",
   "metadata": {},
   "outputs": [],
   "source": [
    "geemap.bar_chart(\n",
    "    df, x=\"NAME\", y=\"sum\", max_rows=30, x_label=\"Country\", y_label=\"Area (km2)\"\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "26",
   "metadata": {},
   "outputs": [],
   "source": [
    "geemap.pie_chart(df, names=\"NAME\", values=\"sum\", max_rows=20, height=500)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "27",
   "metadata": {},
   "source": [
    "## ESRI GLobal Land Cover\n",
    "\n",
    "The ESRI GLobal Land Cover dataset is a global map of land use/land cover (LULC) derived from ESA Sentinel-2 imagery at 10m resolution. Each year is generated from Impact Observatory’s deep learning AI land classification model used a massive training dataset of billions of human-labeled image pixels developed by the National Geographic Society. The global maps were produced by applying this model to the Sentinel-2 scene collection on Microsoft’s Planetary Computer, processing over 400,000 Earth observations per year. \n",
    "\n",
    "- https://livingatlas.arcgis.com/landcover/\n",
    "- https://www.arcgis.com/home/item.html?id=d3da5dd386d140cf93fc9ecbf8da5e31\n",
    "- https://samapriya.github.io/awesome-gee-community-datasets/projects/S2TSLULC/"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "28",
   "metadata": {},
   "source": [
    "### Using Awesome GEE Community Datasets"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "29",
   "metadata": {},
   "outputs": [],
   "source": [
    "Map = geemap.Map()\n",
    "Map.add_basemap(\"HYBRID\")\n",
    "\n",
    "esri = ee.ImageCollection(\n",
    "    \"projects/sat-io/open-datasets/landcover/ESRI_Global-LULC_10m_TS\"\n",
    ")\n",
    "\n",
    "esri_2017 = esri.filterDate(\"2017-01-01\", \"2017-12-31\").mosaic()\n",
    "esri_2018 = esri.filterDate(\"2018-01-01\", \"2018-12-31\").mosaic()\n",
    "esri_2019 = esri.filterDate(\"2019-01-01\", \"2019-12-31\").mosaic()\n",
    "esri_2020 = esri.filterDate(\"2020-01-01\", \"2020-12-31\").mosaic()\n",
    "esri_2021 = esri.filterDate(\"2021-01-01\", \"2021-12-31\").mosaic()\n",
    "\n",
    "esri_vis = {\"min\": 1, \"max\": 11, \"palette\": \"esri_lulc\"}\n",
    "\n",
    "Map.addLayer(esri_2017, esri_vis, \"ESRI LULC 2017\")\n",
    "Map.addLayer(esri_2018, esri_vis, \"ESRI LULC 2018\")\n",
    "Map.addLayer(esri_2019, esri_vis, \"ESRI LULC 2019\")\n",
    "Map.addLayer(esri_2020, esri_vis, \"ESRI LULC 2020\")\n",
    "Map.addLayer(esri_2021, esri_vis, \"ESRI LULC 2021\")\n",
    "\n",
    "Map.add_legend(title=\"ESRI Land Cover\", builtin_legend=\"ESRI_LandCover_TS\")\n",
    "Map"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "30",
   "metadata": {},
   "source": [
    "### Using Timeseries Inspector"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "31",
   "metadata": {},
   "outputs": [],
   "source": [
    "images = ee.List([esri_2017, esri_2018, esri_2019, esri_2020, esri_2021])\n",
    "collection = ee.ImageCollection.fromImages(images)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "32",
   "metadata": {},
   "outputs": [],
   "source": [
    "years = [str(year) for year in range(2017, 2022)]\n",
    "years"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "33",
   "metadata": {},
   "outputs": [],
   "source": [
    "Map = geemap.Map()\n",
    "Map.ts_inspector(collection, years, esri_vis, width=\"80px\")\n",
    "Map.add_legend(title=\"ESRI Land Cover\", builtin_legend=\"ESRI_LandCover_TS\")\n",
    "Map"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "34",
   "metadata": {},
   "source": [
    "### Extracting Croplands"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "35",
   "metadata": {},
   "outputs": [],
   "source": [
    "countries = ee.FeatureCollection(geemap.examples.get_ee_path(\"countries\"))\n",
    "africa = countries.filter(ee.Filter.eq(\"CONTINENT\", \"Africa\"))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "36",
   "metadata": {},
   "outputs": [],
   "source": [
    "cropland_col = collection.map(lambda img: img.eq(5).clipToCollection(africa).selfMask())\n",
    "cropland_ts = cropland_col.toBands().rename(years)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "37",
   "metadata": {},
   "outputs": [],
   "source": [
    "Map = geemap.Map()\n",
    "\n",
    "style = {\"fillColor\": \"00000000\"}\n",
    "Map.addLayer(cropland_col.first(), {\"palette\": [\"#ab6c28\"]}, \"first\")\n",
    "Map.addLayer(countries.style(**style), {}, \"Countries\", False)\n",
    "Map.addLayer(africa.style(**style), {}, \"Africa\")\n",
    "Map.centerObject(africa)\n",
    "\n",
    "Map"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "38",
   "metadata": {},
   "outputs": [],
   "source": [
    "cropland_ts.bandNames().getInfo()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "39",
   "metadata": {},
   "source": [
    "### Zonal Statistics"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "40",
   "metadata": {},
   "outputs": [],
   "source": [
    "geemap.zonal_stats(\n",
    "    cropland_ts, africa, \"esri_cropland.csv\", stat_type=\"SUM\", scale=1000\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "41",
   "metadata": {},
   "outputs": [],
   "source": [
    "df = geemap.csv_to_df(\"esri_cropland.csv\")\n",
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "42",
   "metadata": {},
   "outputs": [],
   "source": [
    "geemap.bar_chart(df, x=\"NAME\", y=years, max_rows=20, legend_title=\"Year\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "43",
   "metadata": {},
   "outputs": [],
   "source": [
    "geemap.pie_chart(df, names=\"NAME\", values=\"2020\", max_rows=20, height=500)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "44",
   "metadata": {},
   "source": [
    "### Analyzing Cropland Gain and Loss"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "45",
   "metadata": {},
   "outputs": [],
   "source": [
    "Map = geemap.Map()\n",
    "Map.add_basemap(\"HYBRID\")\n",
    "\n",
    "cropland_2017 = esri_2017.eq(5).selfMask()\n",
    "cropland_2021 = esri_2021.eq(5).selfMask()\n",
    "\n",
    "cropland_gain = esri_2017.neq(5).And(esri_2021.eq(5)).selfMask()\n",
    "cropland_loss = esri_2017.eq(5).And(esri_2021.neq(5)).selfMask()\n",
    "\n",
    "Map.addLayer(cropland_2017, {\"palette\": \"brown\"}, \"Cropland 2017\", False)\n",
    "Map.addLayer(cropland_2021, {\"palette\": \"cyan\"}, \"Cropland 2021\", False)\n",
    "\n",
    "Map.addLayer(cropland_gain, {\"palette\": \"yellow\"}, \"Cropland gain\")\n",
    "Map.addLayer(cropland_loss, {\"palette\": \"red\"}, \"Cropland loss\")\n",
    "Map"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "46",
   "metadata": {},
   "outputs": [],
   "source": [
    "geemap.zonal_stats(\n",
    "    cropland_gain,\n",
    "    countries,\n",
    "    \"esri_cropland_gain.csv\",\n",
    "    stat_type=\"SUM\",\n",
    "    scale=1000,\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "47",
   "metadata": {},
   "outputs": [],
   "source": [
    "df = geemap.csv_to_df(\"esri_cropland_gain.csv\")\n",
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "48",
   "metadata": {},
   "outputs": [],
   "source": [
    "geemap.bar_chart(\n",
    "    df,\n",
    "    x=\"NAME\",\n",
    "    y=\"sum\",\n",
    "    max_rows=30,\n",
    "    x_label=\"Country\",\n",
    "    y_label=\"Area (km2)\",\n",
    "    title=\"Cropland Gain\",\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "49",
   "metadata": {},
   "outputs": [],
   "source": [
    "geemap.pie_chart(\n",
    "    df, names=\"NAME\", values=\"sum\", max_rows=30, height=500, title=\"Cropland Gain\"\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "50",
   "metadata": {},
   "outputs": [],
   "source": [
    "geemap.zonal_stats(\n",
    "    cropland_loss,\n",
    "    countries,\n",
    "    \"esri_cropland_loss.csv\",\n",
    "    stat_type=\"SUM\",\n",
    "    scale=1000,\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "51",
   "metadata": {},
   "outputs": [],
   "source": [
    "df = geemap.csv_to_df(\"esri_cropland_loss.csv\")\n",
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "52",
   "metadata": {},
   "outputs": [],
   "source": [
    "geemap.bar_chart(\n",
    "    df,\n",
    "    x=\"NAME\",\n",
    "    y=\"sum\",\n",
    "    max_rows=30,\n",
    "    x_label=\"Country\",\n",
    "    y_label=\"Area (km2)\",\n",
    "    title=\"Cropland Loss\",\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "53",
   "metadata": {},
   "outputs": [],
   "source": [
    "geemap.pie_chart(\n",
    "    df, names=\"NAME\", values=\"sum\", max_rows=30, height=500, title=\"Cropland Loss\"\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "54",
   "metadata": {},
   "source": [
    "## Dynamic World Land Cover\n",
    "\n",
    "Dynamic World is a near realtime 10m resolution global land use land cover dataset, produced using deep learning, freely available and openly licensed. As a result of leveraging a novel deep learning approach, based on Sentinel-2 Top of Atmosphere, Dynamic World offers global land cover updating every 2-5 days depending on location. \n",
    "\n",
    "- [Dynamic World Website](https://www.dynamicworld.app/)\n",
    "- [Dynamic World datasets on Earth Engine](https://developers.google.com/earth-engine/datasets/catalog/GOOGLE_DYNAMICWORLD_V1)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "55",
   "metadata": {},
   "source": [
    "### Classification and Probability"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "56",
   "metadata": {},
   "outputs": [],
   "source": [
    "Map = geemap.Map()\n",
    "\n",
    "region = ee.Geometry.BBox(-179, -89, 179, 89)\n",
    "start_date = \"2021-01-01\"\n",
    "end_date = \"2022-01-01\"\n",
    "\n",
    "dw_class = geemap.dynamic_world(region, start_date, end_date, return_type=\"class\")\n",
    "dw = geemap.dynamic_world(region, start_date, end_date, return_type=\"hillshade\")\n",
    "\n",
    "dw_vis = {\"min\": 0, \"max\": 8, \"palette\": \"dw\"}\n",
    "\n",
    "Map.addLayer(dw_class, dw_vis, \"DW Land Cover\", False)\n",
    "Map.addLayer(dw, {}, \"DW Land Cover Hillshade\")\n",
    "\n",
    "Map.add_legend(title=\"Dynamic World Land Cover\", builtin_legend=\"Dynamic_World\")\n",
    "Map.setCenter(-88.9088, 43.0006, 12)\n",
    "Map"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "57",
   "metadata": {},
   "source": [
    "### ESA Land Cover vs. Dynamic World"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "58",
   "metadata": {},
   "outputs": [],
   "source": [
    "Map = geemap.Map(center=[39.3322, -106.7349], zoom=10)\n",
    "\n",
    "left_layer = geemap.ee_tile_layer(esa, esa_vis, \"ESA Land Cover\")\n",
    "right_layer = geemap.ee_tile_layer(dw, {}, \"Dynamic World Land Cover\")\n",
    "\n",
    "Map.split_map(left_layer, right_layer)\n",
    "Map.add_legend(\n",
    "    title=\"ESA Land Cover\", builtin_legend=\"ESA_WorldCover\", position=\"bottomleft\"\n",
    ")\n",
    "Map.add_legend(\n",
    "    title=\"Dynamic World Land Cover\",\n",
    "    builtin_legend=\"Dynamic_World\",\n",
    "    position=\"bottomright\",\n",
    ")\n",
    "Map.setCenter(-88.9088, 43.0006, 12)\n",
    "\n",
    "Map"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "59",
   "metadata": {},
   "source": [
    "### ESRI Land Cover vs. Dynamic World"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "60",
   "metadata": {},
   "outputs": [],
   "source": [
    "Map = geemap.Map(center=[-89.3998, 43.0886], zoom=10)\n",
    "\n",
    "left_layer = geemap.ee_tile_layer(esri_2021, esri_vis, \"ESRI Land Cover\")\n",
    "right_layer = geemap.ee_tile_layer(dw, {}, \"Dynamic World Land Cover\")\n",
    "\n",
    "Map.split_map(left_layer, right_layer)\n",
    "Map.add_legend(\n",
    "    title=\"ESRI Land Cover\", builtin_legend=\"ESRI_LandCover\", position=\"bottomleft\"\n",
    ")\n",
    "Map.add_legend(\n",
    "    title=\"Dynamic World Land Cover\",\n",
    "    builtin_legend=\"Dynamic_World\",\n",
    "    position=\"bottomright\",\n",
    ")\n",
    "Map.setCenter(-88.9088, 43.0006, 12)\n",
    "\n",
    "Map"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
